package com.martin.fastframe.ui.penetrate

import android.annotation.SuppressLint
import android.view.MotionEvent
import com.martin.fastframe.R
import com.martin.fastframe.databinding.FragmentBBinding
import com.martin.lib_base.base.BaseFragment
import com.martin.lib_base.ktx.loge
import com.martin.lib_base.ktx.showToast

class BFragment : BaseFragment<FragmentBBinding>() {

    override fun layoutId() = R.layout.fragment_b

    @SuppressLint("ClickableViewAccessibility")
    override fun initOnViewCreated() {
        binding.rlContent.setOnClickListener {
            loge("B 点击事件 ")
            showToast("B 点击事件 ")
        }

        binding.rlContent.setOnTouchListener { _, event ->

            if (event.action == MotionEvent.ACTION_MOVE) {
                return@setOnTouchListener false
            }
            requireActivity().supportFragmentManager
                .fragments
                .find { it is AFragment }
                ?.let {
                    val onContentTouch = (it as AFragment).onContentTouch(event)
                    loge("内容触摸事件 B : ${event.action} ~ ${event.rawX},${event.rawY} ~ $onContentTouch")
                    return@setOnTouchListener onContentTouch
                }

            return@setOnTouchListener false
        }
    }
}